import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import legacy from '@vitejs/plugin-legacy'

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      '@/': '/',
      '~/': `${path.resolve(__dirname, 'src')}/`
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "~/assets/css/elementPlusTheme.scss" as *;`,
      }
    }
  },
  plugins: [
    vue(),
    legacy({
      targets: ['ie >= 11', 'chrome 52'],
      additionalLegacyPolyfills: ['regenerator-runtime/runtime']
    }),
    AutoImport({
      // imports: ['vue', 'vue-router'],
      resolvers: [ ElementPlusResolver({
        importStyle: 'sass'
      }) ]
    }),
    Components({
      resolvers: [ ElementPlusResolver({
        importStyle: 'sass'
      }) ]
    })
  ]
})
